import { AccountDailyLogin } from "../account_server/dao/AccountDailyLogin";
import { AccountDailyRegister } from "../account_server/dao/AccountDailyRegister";
import { GiveHistoryDao } from "../hall_server/dao/GiveHistoryDao";
import { MatchUserDao } from "../hall_server/dao/MatchUserDao";
import { RoomResultDao } from "../hall_server/dao/RoomResultDao";
import { RoomVideoDao } from "../hall_server/dao/RoomVideoDao";
import { ChargeDao } from "../pay_server/dao/ChargeDao";
import { Config } from "../src/config/Config";
import DateUtil from "../src/engine/utils/DateUtil";
import { Logger } from "../src/engine/utils/Logger";
import { ClubTopDao } from "./dao/ClubTopDao";
import { Club_Freeze_HistoryDao } from "./dao/Club_Freeze_HistoryDao";
import { Club_HistoryDao } from "./dao/Club_HistoryDao";
import { Daily_ResourceDao } from "./dao/Daily_ResourceDao";
import { RoomStatisticsDao } from "./dao/RoomStatisticsDao";
import { User_Coins_HistoryDao } from "./dao/User_Coins_HistoryDao";
import { User_Gems_HistoryDao } from "./dao/User_Gems_HistoryDao";
import { User_Spend_DailyDao } from "./dao/User_Spend_DailyDao";

const checkClearClubHistory_Inteval: number = 1000 * 60 * 60 * 24;//1天检查一次

export class LogClearManager {

    public static instance: LogClearManager = new LogClearManager();

    private last_check_club_time: number = 0

    public checkClear(now: number) {
        this.checkClearClubHistory(now)
        this.req_server_update_server(now)
    }

    private checkClearClubHistory(now: number) {
        if (now - this.last_check_club_time >= checkClearClubHistory_Inteval) {
            let date: Date = new Date()
            if (date.getHours() == 5) { //你见过半夜5点的篮球吗？
                this.last_check_club_time = now;
                let delete_time_7: number = now - Config.OneDay * 7; //保留7天记录
                // Logger.log("LogClearManager===", delete_time_7, DateUtil.formatDateStr(delete_time_7))
                //定时清理俱乐部进出信息
                // Club_HistoryDao.clear_in_out_history(delete_time)
                // //清理俱乐部排行
                // ClubTopDao.clear_club_top(delete_time)
                // //定时清理房间战绩
                // RoomResultDao.checkClearRoomResult(delete_time)
                // //定时清理房间战绩录像
                // RoomVideoDao.checkClear(delete_time)
                // //定时清理俱乐部冻结记录
                // Club_Freeze_HistoryDao.clear(delete_time)
                // //定时清理充值垃圾订单
                // ChargeDao.clear(delete_time)

                // User_Spend_DailyDao.clear()

                // //用户钻石明细
                // User_Gems_HistoryDao.clear(delete_time)
                // User_Coins_HistoryDao.clear(delete_time)

                // Daily_ResourceDao.clear(delete_time)

                // MatchUserDao.clearMatchDaily(delete_time)

                // //定时清理日志
                // GiveHistoryDao.clear(delete_time)

                // RoomStatisticsDao.clear(now - Config.OneDay * 35)

                let delete_time_60: number = now - Config.OneDay * 7;
                AccountDailyLogin.clear(delete_time_60)
                AccountDailyRegister.clear(delete_time_60)

            }
        }
    }


    private req_server_update_server(now: number) {

    }
}